package com.simosoft.unitime.Activities;

import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.chart.BarChart.Type;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.SimpleSeriesRenderer;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.simosoft.unitime.R;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.Paint.Align;
import android.os.Bundle;
import android.view.Window;
import android.widget.LinearLayout;

public class LibrettoActivity extends Activity {

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.libretto);
		setChart();
	}

	private void setChart() {		
		XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
		XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
		
		
		XYSeries series = new XYSeries("Pippo");
		series.add(2.0, 18.0);
		series.add(6.0, 25.0);
		dataset.addSeries(series);
		SimpleSeriesRenderer serrend = new SimpleSeriesRenderer();
		serrend.setColor(Color.BLUE);
		renderer.setXAxisMax(10.0);
		renderer.setYAxisMax(30.0);
		renderer.addSeriesRenderer(serrend);
		renderer.setPanLimits(new double[] { 0, 100, 0, 30 });
	    renderer.setZoomLimits(new double[] { 0, 0, 0, 0 });
	    renderer.setRange(new double[] { 0, 30, 0, 30 });
	    renderer.setZoomEnabled(false, false);
	    renderer.setFitLegend(true);
	    renderer.setBarSpacing(0.5);
		//renderer.setShowLabels(false);
		renderer.setShowCustomTextGrid(true);
		renderer.getSeriesRendererAt(0).setDisplayChartValues(true);
		renderer.getSeriesRendererAt(0).setChartValuesTextAlign(Align.CENTER);
		renderer.setMarginsColor(0x00FFFFFF);
		renderer.setApplyBackgroundColor(true);
		renderer.setAxesColor(Color.BLACK);
		
		
		GraphicalView view = ChartFactory.getBarChartView(this.getBaseContext(), dataset, renderer, Type.DEFAULT);
		view.setBackgroundColor(Color.TRANSPARENT);
		LinearLayout l = (LinearLayout) findViewById(R.id.Row1LinearLayout);
		l.addView(view);
		//renderer.setXLabels(0);
		l.setBackgroundColor(Color.TRANSPARENT);
	}
}
